﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Collections;

/// <summary>
/// Summary description for languageBus
/// </summary>
public class languageBus
{
    languageDAL langDAL;
	public languageBus()
	{
        langDAL = new languageDAL();
		//
		// TODO: Add constructor logic here
		//
	}
    public language getLanguageByID(int language_id)
    {
        language lang=null;
        DataTable dt = langDAL.getLanguageByID(language_id);
        if (!dt.HasErrors)
        {
            foreach (DataRow r in dt.Rows)
            {
                lang = new language(
                        Convert.ToInt32(r["language_id"]),
                        r["name"].ToString(),
                        r["code"].ToString(),
                        r["locale"].ToString(),
                        r["image"].ToString()
                    );
            }
        }
        return lang;
    }
    public DataTable getAllLanguage()
    {
        return langDAL.getAllLanguage();
    }


    public ArrayList getArrayLanguage()
    {
        ArrayList arr = new ArrayList();
        DataTable dt = langDAL.getAllLanguage();
        foreach (DataRow r in dt.Rows)
        {
            language lang = new language(
                                Convert.ToInt32(r["language_id"]),
                                r["name"].ToString(),
                                r["code"].ToString(),
                                r["locale"].ToString(),
                                r["image"].ToString()                
                            );
            arr.Add(lang);
        }
        return arr;
    }


    public DataTable getLanguageID(int language_id)
    {
        return langDAL.getLanguageByID(language_id);
    }

}